package com.dk.service;

import com.dk.mapper.TabCategoryMapper;
import com.dk.pojo.TabCategory;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryServiceImpl implements CategoryService {
    @Autowired
    private TabCategoryMapper tabCategoryMapper;

    @Override
    public PageInfo<TabCategory> selectserver(String cname,  Integer pageNumber, Integer pageSize) {
        PageHelper.startPage(pageNumber, pageSize);
        List<TabCategory> list = tabCategoryMapper.seelctBname(cname);
        PageInfo<TabCategory> page = new PageInfo<>(list);
        return page;
    }

    @Override
    public boolean insertInfo(TabCategory c) {
        int i = tabCategoryMapper.insertSelective(c);
        return i > 0;
    }

    @Override
    public TabCategory selectBcid(Integer cid) {
        TabCategory tabCategory = tabCategoryMapper.selectByPrimaryKey(cid);
        return tabCategory;
    }

    @Override
    public boolean updateInfo(TabCategory t) {
        int i = tabCategoryMapper.updateByPrimaryKeySelective(t);
        return i>0;
    }

    @Override
    public boolean deleteById(Integer id) {
        int i = tabCategoryMapper.deleteByPrimaryKey(id);

        return i>0;
    }

    @Override
    public boolean deleteshanchu(Integer[] ids) {
            int a =  tabCategoryMapper.deleByids(ids);
        return a>0;
    }


}
